<html xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <title>Register</title>
</head>
<style>
    .message{
        color: #ff0000;
    }
</style>
<body>
    <div class="main">
        <div class="form">
            <form onsubmit="return false">
                <table>
                    <tr>
                        <td> <span class="message"></span> </td>
                    </tr>
                    <tr>
                        <td>新密码：</td>
                        <td><input type="password" name="newpassword"/></td>
                    </tr>
                    <tr>
                        <td>重复密码: </td>
                        <td><input type="password" name="repassword"/></td>
                    </tr>
                    <tr>
                        <td><input type="submit" class="js_submit" value="提交"/></td>
                    </tr>
                </table>
            </form>
        </div>
    </div>

</body>
    <script th:src="@{/js/jquery-3.2.1.min.js}"></script>
    <script th:inline="javascript">
        $('.js_submit').off('click').on('click',function () {
            var _value = {
                newpassword:$('input[name=newpassword]').val(),
                repassword:$('input[name=repassword]').val(),
                token:[[${token}]]
            };
            $.ajax({
                type:'PUT',
                url:"/auth/reset",
                async:false,
                data:JSON.stringify(_value),
                dataType:'json',
                contentType:"application/json",
                success:function(data){
                    console.log(JSON.stringify(data));
                    var code = data.code;
                    if (code == "200"){
                        $('.form').remove();
                        $('.main').html(data.payload);
                    }else {
                        $('.message').text(data.payload);
                    }
                },
                error:function(msg){
                    alert("连接服务器失败");
                }
            });
        });
    </script>
</html>